﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AddIn.EA.Framework.Common;

namespace AddIn.EA.Framework
{
    /// <summary>
    /// Class that represent a list of parameter. Composite the Method class.
    /// </summary>
    public class ParameterList : BaseList<Parameter>
    {
        #region Constructors
        /// <summary>
        /// Get an instance of parameters list.
        /// </summary>
        /// <param name="reference">The reference of EA Object Model parameter collection.</param>
        /// <param name="parent">The parent element.</param>
        public ParameterList(EA_Application.Collection reference, IElement parent)
            : base(reference, parent) { }
        #endregion
    }

    /// <summary>
    /// Class that represent a parameter.
    /// </summary>
    public class Parameter : BaseElement<EA_Application.Parameter>
    {
        #region Constructors
        /// <summary>
        /// Get an instance of parameter.
        /// </summary>
        /// <param name="reference">The reference of EA Object Model parameter.</param>
        /// <param name="parent">The parent element.</param>
        public Parameter(EA_Application.Parameter reference, IElement parent)
            : base(reference, parent) { }
        #endregion

        #region Properties

        #region BaseElement Members
        /// <summary>
        /// The parameter id.
        /// </summary>
        public override int ID
        {
            get { return 0; }
        }
        /// <summary>
        /// The parameter name.
        /// </summary>
        public override string Name
        {
            get
            {
                return this.Reference.Name;
            }
            set
            {
                this.Reference.Name = value;
            }
        }
        #endregion

        /// <summary>
        /// Notes for parameter.
        /// </summary>
        public string Notes
        {
            get { return this.Reference.Notes; }
            set { this.Reference.Notes = value; }
        }
        /// <summary>
        /// The kind of parameter. Can be In, Out or InOut parameter.
        /// </summary>
        public ParameterKind Kind
        {
            get 
            {
                if (String.IsNullOrEmpty(this.Reference.Kind))
                    return default(ParameterKind);

                try
                {
                    return (ParameterKind)Enum.Parse(typeof(ParameterKind), this.Reference.Kind, true);
                }
                catch { return default(ParameterKind); }
            }
            set { this.Reference.Kind = value.ToString(); }
        }
        /// <summary>
        /// The parameter stereotype.
        /// </summary>
        public string Stereotype
        {
            get { return this.Reference.Stereotype; }
            set { this.Reference.Stereotype = value; }
        }
        /// <summary>
        /// The parameter type.
        /// </summary>
        public string Type
        {
            get { return this.Reference.Type; }
            set { this.Reference.Type = value; }
        }
        #endregion
    }
}
